//
//  ViewController.swift
//  Xylophone
//
//  Created by 刘军 on 2021/10/12.
//

import UIKit
import AVFoundation
class ViewController: UIViewController {
    
    var player: AVAudioPlayer!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    
    @IBAction func playmusic(_ sender: UIButton) {
        var index1 = sender.tag
        var url = Bundle.main.url(forResource: "note\(index1)", withExtension: "wav")!
        do{
            player = try AVAudioPlayer(contentsOf: url)
            player.play()
        }catch{
            print(error)
        }
        
    }
    
}

